home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / include / GL / osmesa.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-19  |  6.7 KB  |  235 lines

  1. /* $Id: osmesa.h,v 1.5 1997/02/19 10:13:54 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.2
  6.  * Copyright (C) 1995-1997  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: osmesa.h,v $
  26.  * Revision 1.5  1997/02/19 10:13:54  brianp
  27.  * now test for __QUICKDRAW__ like for __BEOS__ (Randy Frank)
  28.  *
  29.  * Revision 1.4  1997/02/10 20:31:41  brianp
  30.  * added OSMESA_RGB and OSMESA_BGR, per Randy Frank
  31.  *
  32.  * Revision 1.3  1997/02/03 20:07:40  brianp
  33.  * patches for BeOS
  34.  *
  35.  * Revision 1.2  1996/10/30 03:12:30  brianp
  36.  * incremented version to 2.1
  37.  *
  38.  * Revision 1.1  1996/09/13 01:26:41  brianp
  39.  * Initial revision
  40.  *
  41.  */
  42.  
  43.  
  44. /*
  45.  * Mesa Off-Screen rendering interface.
  46.  *
  47.  * This is an operating system and window system independent interface to
  48.  * Mesa which allows one to render images into a client-supplied buffer in
  49.  * main memory.  Such images may manipulated or saved in whatever way the
  50.  * client wants.
  51.  *
  52.  * These are the API functions:
  53.  *   OSMesaCreateContext - create a new Off-Screen Mesa rendering context
  54.  *   OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
  55.  *                       and make the specified context the current one.
  56.  *   OSMesaDestroyContext - destroy an OSMesaContext
  57.  *   OSMesaGetCurrentContext - return thread's current context ID
  58.  *   OSMesaPixelStore - controls how pixels are stored in image buffer
  59.  *   OSMesaGetIntegerv - return OSMesa state parameters
  60.  *
  61.  *
  62.  * The limits on the width and height of an image buffer are MAX_WIDTH and
  63.  * MAX_HEIGHT as defined in Mesa/src/config.h.  Defaults are 1280 and 1024.
  64.  * You can increase them as needed but beware that many temporary arrays in
  65.  * Mesa are dimensioned by MAX_WIDTH or MAX_WIDTH.
  66.  */
  67.  
  68.  
  69.  
  70. #ifndef OSMESA_H
  71. #define OSMESA_H
  72.  
  73.  
  74.  
  75. #ifdef __cplusplus
  76. extern "C" {
  77. #endif
  78.  
  79.  
  80. #include "GL/gl.h"
  81.  
  82.  
  83.  
  84. #define OSMESA_MAJOR_VERSION 2
  85. #define OSMESA_MINOR_VERSION 1
  86.  
  87.  
  88.  
  89. /*
  90.  * Values for the format parameter of OSMesaCreateContext()
  91.  * New in version 2.0.
  92.  */
  93. #define OSMESA_COLOR_INDEX    GL_COLOR_INDEX
  94. #define OSMESA_RGBA        GL_RGBA
  95. #define OSMESA_BGRA        0x1
  96. #define OSMESA_ARGB        0x2
  97. #define OSMESA_RGB        GL_RGB
  98. #define OSMESA_BGR        0x4
  99.  
  100.  
  101. /*
  102.  * OSMesaPixelStore() parameters:
  103.  * New in version 2.0.
  104.  */
  105. #define OSMESA_ROW_LENGTH    0x10
  106. #define OSMESA_Y_UP        0x11
  107.  
  108.  
  109. /*
  110.  * Accepted by OSMesaGetIntegerv:
  111.  */
  112. #define OSMESA_WIDTH        0x20
  113. #define OSMESA_HEIGHT        0x21
  114. #define OSMESA_FORMAT        0x22
  115. #define OSMESA_TYPE        0x23
  116.  
  117.  
  118.  
  119. typedef struct osmesa_context *OSMesaContext;
  120.  
  121.  
  122. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  123. #pragma export on
  124. #endif
  125.  
  126.  
  127. /*
  128.  * Create an Off-Screen Mesa rendering context.  The only attribute needed is
  129.  * an RGBA vs Color-Index mode flag.
  130.  *
  131.  * Input:  format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
  132.  *                  OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
  133.  *         sharelist - specifies another OSMesaContext with which to share
  134.  *                     display lists.  NULL indicates no sharing.
  135.  * Return:  an OSMesaContext or 0 if error
  136.  */
  137. extern OSMesaContext OSMesaCreateContext( GLenum format,
  138.                                           OSMesaContext sharelist );
  139.  
  140.  
  141.  
  142.  
  143. /*
  144.  * Destroy an Off-Screen Mesa rendering context.
  145.  *
  146.  * Input:  ctx - the context to destroy
  147.  */
  148. extern void OSMesaDestroyContext( OSMesaContext ctx );
  149.  
  150.  
  151.  
  152. /*
  153.  * Bind an OSMesaContext to an image buffer.  The image buffer is just a
  154.  * block of memory which the client provides.  Its size must be at least
  155.  * as large as width*height*sizeof(type).  Its address should be a multiple
  156.  * of 4 if using RGBA mode.
  157.  *
  158.  * Image data is stored in the order of glDrawPixels:  row-major order
  159.  * with the lower-left image pixel stored in the first array position
  160.  * (ie. bottom-to-top).
  161.  *
  162.  * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
  163.  * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
  164.  * value.  If the context is in color indexed mode, each pixel will be
  165.  * stored as a 1-byte value.
  166.  *
  167.  * If the context's viewport hasn't been initialized yet, it will now be
  168.  * initialized to (0,0,width,height).
  169.  *
  170.  * Input:  ctx - the rendering context
  171.  *         buffer - the image buffer memory
  172.  *         type - data type for pixel components, only GL_UNSIGNED_BYTE
  173.  *                supported now
  174.  *         width, height - size of image buffer in pixels, at least 1
  175.  * Return:  GL_TRUE if success, GL_FALSE if error because of invalid ctx,
  176.  *          invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
  177.  *          width>internal limit or height>internal limit.
  178.  */
  179. extern GLboolean OSMesaMakeCurrent( OSMesaContext ctx,
  180.                                     void *buffer, GLenum type,
  181.                                     GLsizei width, GLsizei height );
  182.  
  183.  
  184.  
  185.  
  186. /*
  187.  * Return the current Off-Screen Mesa rendering context handle.
  188.  */
  189. extern OSMesaContext OSMesaGetCurrentContext( void );
  190.  
  191.  
  192.  
  193. /*
  194.  * Set pixel store/packing parameters for the current context.
  195.  * This is similar to glPixelStore.
  196.  * Input:  pname - OSMESA_ROW_LENGTH
  197.  *                    specify actual pixels per row in image buffer
  198.  *                    0 = same as image width (default)
  199.  *                 OSMESA_Y_UP
  200.  *                    zero = Y coordinates increase downward
  201.  *                    non-zero = Y coordinates increase upward (default)
  202.  *         value - the value for the parameter pname
  203.  *
  204.  * New in version 2.0.
  205.  */
  206. extern void OSMesaPixelStore( GLint pname, GLint value );
  207.  
  208.  
  209.  
  210. /*
  211.  * Return context info.  This is like glGetIntegerv.
  212.  * Input:  pname -
  213.  *                 OSMESA_WIDTH  return current image width
  214.  *                 OSMESA_HEIGHT  return current image height
  215.  *                 OSMESA_FORMAT  return image format
  216.  *                 OSMESA_TYPE  return color component data type
  217.  *                 OSMESA_ROW_LENGTH return row length in pixels
  218.  *                 OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
  219.  *         value - pointer to integer in which to return result.
  220.  */
  221. extern void OSMesaGetIntegerv( GLint pname, GLint *value );
  222.  
  223.  
  224. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  225. #pragma export off
  226. #endif
  227.  
  228.  
  229. #ifdef __cplusplus
  230. }
  231. #endif
  232.  
  233.  
  234. #endif
  235.